package com.weslide.weslideapp.fragment;

import com.weslide.weslideapp.R;
import com.weslide.weslideapp.manager.api.LoginManager;
import com.weslide.weslideapp.pojo.ao.LoginAO;

import android.R.raw;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;

public class UserCenterFragment extends WeSlideFragment {
	public static final String TAG = "UserCenterFragment";
	private TextView mTvMyNickname;
	private TextView mTvMyScore;
	private TextView mTvSaveMoney;

	// private View mLlExchangeLayout;
	// private View mLlMyMessage;
	// private View mLlMyInvitation;
	// private View mLlMyProfile;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		globalView = inflater.inflate(R.layout.page_user_center, container,
				false);
		findViews();

		return globalView;
	}

	@Override
	public void onResume() {
		init();
		super.onResume();
	}

	private void findViews() {
		mTvMyNickname = (TextView) findViewById(R.id.page_user_center_mTvMyNickname);
		mTvMyScore = (TextView) findViewById(R.id.page_user_center_mTvMyScore);
		mTvSaveMoney = (TextView) findViewById(R.id.page_user_center_mTvSaveMoney);
		findViewById(R.id.page_user_center_mLlExchangeLayout)
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						getGlobalNavigatrionFragment().push(
								new MyExchangeRecord(), false);
					}
				});

		findViewById(R.id.page_user_center_mLlMyMessage).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						getGlobalNavigatrionFragment().push(
								new MyMessageFragment(), false);
					}
				});
		findViewById(R.id.page_user_center_mLlMyInvitation).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						getGlobalNavigatrionFragment().push(
								new MyInvitationFragment(), false);
					}
				});
		findViewById(R.id.page_user_center_mLlMyProfile).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						getGlobalNavigatrionFragment().push(
								new MyProfileFragment(), false);
					}
				});
	}

	private void init() {
		LoginAO userInformation = LoginManager.getInstance()
				.getUserInformation();
		mTvMyNickname.setText(userInformation.getName());
		mTvMyScore.setText(userInformation.getScore());
		mTvSaveMoney.setText(userInformation.getSaveMoney());
	}
}
